/*    */ package cn.zzuisa.news.servlet;
/*    */ 
/*    */ import cn.zzuisa.news.entity.News;
/*    */ import cn.zzuisa.news.enums.CommonEnums;
/*    */ import cn.zzuisa.news.service.NewsService;
/*    */ import cn.zzuisa.news.service.impl.NewsServiceImpl;
/*    */ import cn.zzuisa.news.util.JsonUtil;
/*    */ import cn.zzuisa.news.util.ResultVOUtil;
/*    */ import java.io.IOException;
/*    */ import java.util.List;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.annotation.WebServlet;
/*    */ import javax.servlet.http.HttpServlet;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ @WebServlet(name = "index", urlPatterns = {"/index"}, asyncSupported = true)
/*    */ public class IndexServlet
/*    */   extends HttpServlet
/*    */ {
/*    */   private static final long serialVersionUID = 1L;
/* 28 */   private NewsService newsServiceImpl = new NewsServiceImpl();
/*    */ 
/*    */   
/*    */   protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
/* 32 */     String method = req.getParameter("method");
/* 33 */     if (method == null) {
/* 34 */       req.setAttribute("list", this.newsServiceImpl.listpass());
/* 35 */       req.getRequestDispatcher("WEB-INF/ftl/index/index.ftl").forward(req, resp);
/* 36 */     } else if (method.equals("list")) {
/* 37 */       if (req.getSession().getAttribute("user") == null) {
/* 38 */         resp.getWriter().println(JsonUtil.setData(ResultVOUtil.failed(CommonEnums.USER_NOT_LOGIN)));
/*    */         return;
/*    */       } 
/* 41 */       List<News> newslist = this.newsServiceImpl.list();
/* 42 */       if (newslist != null)
/*    */       {
/* 44 */         resp.getWriter().println(JsonUtil.setData(ResultVOUtil.success(newslist)));
/*    */       }
/*    */     } 
/*    */   }
/*    */ }


/* Location:              /Users/frank/Desktop/admin/WEB-INF/classes/!/cn/zzuisa/news/servlet/IndexServlet.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.0.7
 */